import { defineStore } from "pinia";
import { store } from "@/store";
import { urlType } from "./types";

export const useURLStore = defineStore({
  id: "proxy_story",
  state: (): urlType => ({
    id: 0,
    tableName: "",
    deptId: 0,
    isEdit: false
  }),
  getters: {
    getID(state) {
      return state.id;
    },
    getTableName(state) {
      return state.tableName;
    },
    getIsEdit(state) {
      return state.isEdit;
    }
  },
  actions: {
    setURL({ id, tableName, deptId, isEdit }) {
      this.id = id;
      this.tableName = tableName;
      this.isEdit = isEdit;
      this.deptId = deptId;
    }
  }
});

export function useURLStoreHook() {
  return useURLStore(store);
}
